using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
    public class ContractInfo
    {
		#region Local Variable
        public enum Field
        {
			Contract,
			LimitAmt,
			CIT,
			VAT,
			CummulativeAmt,
			RemainingAmt,
			ContractHolder,
			Desc,
			Department,
			SharedContract,
			ActualCost,
			SignDate,
			EffectiveDate,
			ExpiryDate,
			PaymentTerm,
			Remark1,
			Remark2,
			Remark3,
			MCApproval,
			ActionRequired,
			Status,
			BudgetCode,
			BudgetYear,
			YearBudgetCode,
			VendorCode,
			VendorName,
			Cur,
			UserRef,
			ContractType,
			isLink,
			aType
        }
		private String _Contract;
		public String Contract
		{
			get { return _Contract; }
			set { _Contract = value; }
		}
		private Double _LimitAmt;
		public Double LimitAmt
		{
			get { return _LimitAmt; }
			set { _LimitAmt = value; }
		}
		private Double _CIT;
		public Double CIT
		{
			get { return _CIT; }
			set { _CIT = value; }
		}
		private Double _VAT;
		public Double VAT
		{
			get { return _VAT; }
			set { _VAT = value; }
		}
		private Double _CummulativeAmt;
		public Double CummulativeAmt
		{
			get { return _CummulativeAmt; }
			set { _CummulativeAmt = value; }
		}
		private Double _RemainingAmt;
		public Double RemainingAmt
		{
			get { return _RemainingAmt; }
			set { _RemainingAmt = value; }
		}
		private String _ContractHolder;
		public String ContractHolder
		{
			get { return _ContractHolder; }
			set { _ContractHolder = value; }
		}
		private String _Desc;
		public String Desc
		{
			get { return _Desc; }
			set { _Desc = value; }
		}
		private String _Department;
		public String Department
		{
			get { return _Department; }
			set { _Department = value; }
		}
		private Int32 _SharedContract;
		public Int32 SharedContract
		{
			get { return _SharedContract; }
			set { _SharedContract = value; }
		}
		private Double _ActualCost;
		public Double ActualCost
		{
			get { return _ActualCost; }
			set { _ActualCost = value; }
		}
		private DateTime _SignDate;
		public DateTime SignDate
		{
			get { return _SignDate; }
			set { _SignDate = value; }
		}
		private DateTime _EffectiveDate;
		public DateTime EffectiveDate
		{
			get { return _EffectiveDate; }
			set { _EffectiveDate = value; }
		}
		private DateTime _ExpiryDate;
		public DateTime ExpiryDate
		{
			get { return _ExpiryDate; }
			set { _ExpiryDate = value; }
		}
		private Int16 _PaymentTerm;
		public Int16 PaymentTerm
		{
			get { return _PaymentTerm; }
			set { _PaymentTerm = value; }
		}
		private String _Remark1;
		public String Remark1
		{
			get { return _Remark1; }
			set { _Remark1 = value; }
		}
		private String _Remark2;
		public String Remark2
		{
			get { return _Remark2; }
			set { _Remark2 = value; }
		}
		private String _Remark3;
		public String Remark3
		{
			get { return _Remark3; }
			set { _Remark3 = value; }
		}
		private Int32 _MCApproval;
		public Int32 MCApproval
		{
			get { return _MCApproval; }
			set { _MCApproval = value; }
		}
		private String _ActionRequired;
		public String ActionRequired
		{
			get { return _ActionRequired; }
			set { _ActionRequired = value; }
		}
		private String _Status;
		public String Status
		{
			get { return _Status; }
			set { _Status = value; }
		}
		private String _BudgetCode;
		public String BudgetCode
		{
			get { return _BudgetCode; }
			set { _BudgetCode = value; }
		}
		private Int32 _BudgetYear;
		public Int32 BudgetYear
		{
			get { return _BudgetYear; }
			set { _BudgetYear = value; }
		}
		private String _YearBudgetCode;
		public String YearBudgetCode
		{
			get { return _YearBudgetCode; }
			set { _YearBudgetCode = value; }
		}
		private String _VendorCode;
		public String VendorCode
		{
			get { return _VendorCode; }
			set { _VendorCode = value; }
		}
		private String _VendorName;
		public String VendorName
		{
			get { return _VendorName; }
			set { _VendorName = value; }
		}
		private String _Cur;
		public String Cur
		{
			get { return _Cur; }
			set { _Cur = value; }
		}
		private String _UserRef;
		public String UserRef
		{
			get { return _UserRef; }
			set { _UserRef = value; }
		}
		private String _ContractType;
		public String ContractType
		{
			get { return _ContractType; }
			set { _ContractType = value; }
		}
		private Int16 _isLink;
		public Int16 isLink
		{
			get { return _isLink; }
			set { _isLink = value; }
		}
		private String _aType;
		public String aType
		{
			get { return _aType; }
			set { _aType = value; }
		}
        #endregion LocalVariable
        
        #region Constructor

		public ContractInfo()
		{
			_Contract = "";
			_LimitAmt = 0;
			_CIT = 0;
			_VAT = 0;
			_CummulativeAmt = 0;
			_RemainingAmt = 0;
			_ContractHolder = "";
			_Desc = "";
			_Department = "";
			_SharedContract = -1;
			_ActualCost = 0;
            _SignDate = DateTime.MinValue;
            _EffectiveDate = DateTime.MinValue;
            _ExpiryDate = DateTime.MinValue;
			_PaymentTerm = (Int16)0;
			_Remark1 = "";
			_Remark2 = "";
			_Remark3 = "";
			_MCApproval = -1;
			_ActionRequired = "";
			_Status = "";
			_BudgetCode = "";
			_BudgetYear = -1;
			_YearBudgetCode = "";
			_VendorCode = "";
			_VendorName = "";
			_Cur = "";
			_UserRef = "";
			_ContractType = "";
			_isLink = (Int16)0;
			_aType = "";
		}
		public ContractInfo(
			String Contract,
			Double LimitAmt,
			Double CIT,
			Double VAT,
			Double CummulativeAmt,
			Double RemainingAmt,
			String ContractHolder,
			String Desc,
			String Department,
			Int32 SharedContract,
			Double ActualCost,
			DateTime SignDate,
			DateTime EffectiveDate,
			DateTime ExpiryDate,
			Int16 PaymentTerm,
			String Remark1,
			String Remark2,
			String Remark3,
			Int32 MCApproval,
			String ActionRequired,
			String Status,
			String BudgetCode,
			Int32 BudgetYear,
			String YearBudgetCode,
			String VendorCode,
			String VendorName,
			String Cur,
			String UserRef,
			String ContractType,
			Int16 isLink,
			String aType
			)
		{
			_Contract = Contract;
			_LimitAmt = LimitAmt;
			_CIT = CIT;
			_VAT = VAT;
			_CummulativeAmt = CummulativeAmt;
			_RemainingAmt = RemainingAmt;
			_ContractHolder = ContractHolder;
			_Desc = Desc;
			_Department = Department;
			_SharedContract = SharedContract;
			_ActualCost = ActualCost;
			_SignDate = SignDate;
			_EffectiveDate = EffectiveDate;
			_ExpiryDate = ExpiryDate;
			_PaymentTerm = PaymentTerm;
			_Remark1 = Remark1;
			_Remark2 = Remark2;
			_Remark3 = Remark3;
			_MCApproval = MCApproval;
			_ActionRequired = ActionRequired;
			_Status = Status;
			_BudgetCode = BudgetCode;
			_BudgetYear = BudgetYear;
			_YearBudgetCode = YearBudgetCode;
			_VendorCode = VendorCode;
			_VendorName = VendorName;
			_Cur = Cur;
			_UserRef = UserRef;
			_ContractType = ContractType;
			_isLink = isLink;
			_aType = aType;
		}
		public ContractInfo(DataRowView dr)
		{
            
			if (dr != null)
			{
				_Contract = dr["Contract"] == DBNull.Value ? "" : (String)dr["Contract"];
				_LimitAmt = dr["LimitAmt"] == DBNull.Value ? 0 : (Double)dr["LimitAmt"];
				_CIT = dr["CIT"] == DBNull.Value ? 0 : (Double)dr["CIT"];
				_VAT = dr["VAT"] == DBNull.Value ? 0 : (Double)dr["VAT"];
				_CummulativeAmt = dr["CummulativeAmt"] == DBNull.Value ? 0 : (Double)dr["CummulativeAmt"];
				_RemainingAmt = dr["RemainingAmt"] == DBNull.Value ? 0 : (Double)dr["RemainingAmt"];
				_ContractHolder = dr["ContractHolder"] == DBNull.Value ? "" : (String)dr["ContractHolder"];
				_Desc = dr["Desc"] == DBNull.Value ? "" : (String)dr["Desc"];
				_Department = dr["Department"] == DBNull.Value ? "" : (String)dr["Department"];
				_SharedContract = dr["SharedContract"] == DBNull.Value ? -1 : (Int32)dr["SharedContract"];
				_ActualCost = dr["ActualCost"] == DBNull.Value ? 0 : (Double)dr["ActualCost"];
                _SignDate = dr["SignDate"] == DBNull.Value ? DateTime.MinValue  : (DateTime)dr["SignDate"];
                _EffectiveDate = dr["EffectiveDate"] == DBNull.Value ? DateTime.MinValue : (DateTime)dr["EffectiveDate"];
                _ExpiryDate = dr["ExpiryDate"] == DBNull.Value ? DateTime.MinValue : (DateTime)dr["ExpiryDate"];
				_PaymentTerm = dr["PaymentTerm"] == DBNull.Value ? (Int16)0 : (Int16)dr["PaymentTerm"];
				_Remark1 = dr["Remark1"] == DBNull.Value ? "" : (String)dr["Remark1"];
				_Remark2 = dr["Remark2"] == DBNull.Value ? "" : (String)dr["Remark2"];
				_Remark3 = dr["Remark3"] == DBNull.Value ? "" : (String)dr["Remark3"];
				_MCApproval = dr["MCApproval"] == DBNull.Value ? -1 : (Int32)dr["MCApproval"];
				_ActionRequired = dr["ActionRequired"] == DBNull.Value ? "" : (String)dr["ActionRequired"];
				_Status = dr["Status"] == DBNull.Value ? "" : (String)dr["Status"];
				_BudgetCode = dr["BudgetCode"] == DBNull.Value ? "" : (String)dr["BudgetCode"];
				_BudgetYear = dr["BudgetYear"] == DBNull.Value ? -1 : (Int32)dr["BudgetYear"];
				_YearBudgetCode = dr["YearBudgetCode"] == DBNull.Value ? "" : (String)dr["YearBudgetCode"];
				_VendorCode = dr["VendorCode"] == DBNull.Value ? "" : (String)dr["VendorCode"];
				_VendorName = dr["VendorName"] == DBNull.Value ? "" : (String)dr["VendorName"];
				_Cur = dr["Cur"] == DBNull.Value ? "" : (String)dr["Cur"];
				_UserRef = dr["UserRef"] == DBNull.Value ? "" : (String)dr["UserRef"];
				_ContractType = dr["ContractType"] == DBNull.Value ? "" : (String)dr["ContractType"];
				_isLink = dr["isLink"] == DBNull.Value ? (Int16)0 : (Int16)dr["isLink"];
				_aType = dr["aType"] == DBNull.Value ? "" : (String)dr["aType"];
			}
		}
        #endregion Constructor
        
        #region InitTable
		public DataTable ToDataTable()
		{
			DataTable dt = new DataTable("TblContract");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn("Contract", typeof(String)),
				new DataColumn("LimitAmt", typeof(Double)),
				new DataColumn("CIT", typeof(Double)),
				new DataColumn("VAT", typeof(Double)),
				new DataColumn("CummulativeAmt", typeof(Double)),
				new DataColumn("RemainingAmt", typeof(Double)),
				new DataColumn("ContractHolder", typeof(String)),
				new DataColumn("Desc", typeof(String)),
				new DataColumn("Department", typeof(String)),
				new DataColumn("SharedContract", typeof(Int32)),
				new DataColumn("ActualCost", typeof(Double)),
				new DataColumn("SignDate", typeof(DateTime)),
				new DataColumn("EffectiveDate", typeof(DateTime)),
				new DataColumn("ExpiryDate", typeof(DateTime)),
				new DataColumn("PaymentTerm", typeof(Int16)),
				new DataColumn("Remark1", typeof(String)),
				new DataColumn("Remark2", typeof(String)),
				new DataColumn("Remark3", typeof(String)),
				new DataColumn("MCApproval", typeof(Int32)),
				new DataColumn("ActionRequired", typeof(String)),
				new DataColumn("Status", typeof(String)),
				new DataColumn("BudgetCode", typeof(String)),
				new DataColumn("BudgetYear", typeof(Int32)),
				new DataColumn("YearBudgetCode", typeof(String)),
				new DataColumn("VendorCode", typeof(String)),
				new DataColumn("VendorName", typeof(String)),
				new DataColumn("Cur", typeof(String)),
				new DataColumn("UserRef", typeof(String)),
				new DataColumn("ContractType", typeof(String)),
				new DataColumn("isLink", typeof(Int16)),
				new DataColumn("aType", typeof(String))
				});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row["Contract"] = _Contract;
			row["LimitAmt"] = _LimitAmt;
			row["CIT"] = _CIT;
			row["VAT"] = _VAT;
			row["CummulativeAmt"] = _CummulativeAmt;
			row["RemainingAmt"] = _RemainingAmt;
			row["ContractHolder"] = _ContractHolder;
			row["Desc"] = _Desc;
			row["Department"] = _Department;
			row["SharedContract"] = _SharedContract;
			row["ActualCost"] = _ActualCost;
			row["SignDate"] = _SignDate;
			row["EffectiveDate"] = _EffectiveDate;
			row["ExpiryDate"] = _ExpiryDate;
			row["PaymentTerm"] = _PaymentTerm;
			row["Remark1"] = _Remark1;
			row["Remark2"] = _Remark2;
			row["Remark3"] = _Remark3;
			row["MCApproval"] = _MCApproval;
			row["ActionRequired"] = _ActionRequired;
			row["Status"] = _Status;
			row["BudgetCode"] = _BudgetCode;
			row["BudgetYear"] = _BudgetYear;
			row["YearBudgetCode"] = _YearBudgetCode;
			row["VendorCode"] = _VendorCode;
			row["VendorName"] = _VendorName;
			row["Cur"] = _Cur;
			row["UserRef"] = _UserRef;
			row["ContractType"] = _ContractType;
			row["isLink"] = _isLink;
			row["aType"] = _aType;
			return row;
		}
        #endregion InitTable
    }
}
